Skip to content

Conversation

@rgommers
Copy link
Contributor

Addresses a comment on gh-704, where a user got tripped up by python -m build building an sdist first (and that's typically not what you want).

@rgommers rgommers added the documentation Improvements or additions to documentation label Nov 14, 2024
@dnicolodi
Copy link
Member

We have several other example python -m build invocation in the documentation? Should we change them to python -m build --wheel or is this the time to add that "Creating a binary distribution" we have been talking about and have a note there about the pypa/build unexpected behavior?

@rgommers
Copy link
Contributor Author

rgommers commented Dec 5, 2024

I think we should add --wheel to all other instances of python -m build. The default is useful only for a single CI job or a release of a pure Python package; I can't think of any time I regularly did not add --wheel or -wnx.

@rgommers rgommers force-pushed the add-wheel-flag-to-build branch from 717af2c to 0e1ee55 Compare May 2, 2025 12:31
@rgommers rgommers force-pushed the add-wheel-flag-to-build branch from 0e1ee55 to cf6e2a7 Compare May 2, 2025 12:43
@rgommers rgommers added this to the v0.19.0 milestone May 27, 2025
@rgommers
Copy link
Contributor Author

@dnicolodi this is ready, CI failures were unrelated - PTAL, would be nice to merge it.

If the build succeeded, you'll have the binary artifacts in the ``dist`` folder.
Note that by default, ``python -m build`` builds an sdist first, and then a
wheel from the sdist. If you only want one artifact, add ``--sdist`` or
``--wheel`` to the invocation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this misses the main point. The issue in not the extra work for building an sdist that will not be used, but that doing so any uncommitted change in the repository is not reflected in the wheel.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point, will add that as the first point since it's indeed a footgun. I think both can be relevant; sdist creation for a large project can be really slow (a quick unscientific measurement says 40 seconds for scipy at the moment, and it might breaking caching on rebuilds as well).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a note on uncommitted changes two paragraphs up, where it already talks about Git.

to your Git repository - ``meson-python`` will only take into account the files
that Git knows about.
that Git knows about, and an sdist is created from the most recent commit -
uncommitted changes are ignored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This paragraph is very confusing. What is committed only affects what gets into an sdist, but this section is actually about building a wheel. I think this paragraph needs to be removed and the note about uncommitted changes moved below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's about both sdist and wheels. It's part of the "Creating your first release" section, and clearly does talk about both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to change it to an admonition while we're at it, but I really just want to get this PR in - it was about adding the --wheel flag and not related to the commit status of files at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not make this paragraph worse, so we can merge this PR and fix this part of the documentation later.

Addresses a comment on issue 704, where a user got tripped up
by `python -m build` building an sdist first (and that's typically
not what you want).
@dnicolodi dnicolodi force-pushed the add-wheel-flag-to-build branch from ad68bf0 to 7ee01a1 Compare November 1, 2025 19:05
@dnicolodi dnicolodi changed the title DOC: minor tweak to docs on invoking pip/build DOC: minor tweak to docs on invoking pypa/build Nov 1, 2025
@dnicolodi
Copy link
Member

I took the liberty of fixing the commit title (this does not touch how pip is invoked, thus I think the commit title was a typo)

@dnicolodi dnicolodi merged commit 0444e63 into mesonbuild:main Nov 1, 2025
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants